<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /fasttmp/mkdist-qt-4.3.5-1211793125/qtopia-core-opensource-src-4.3.5/src/qt3support/text/q3textbrowser.cpp -->
<head>
  <title>Qt 4.3: Q3TextBrowser Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">Q3TextBrowser Class Reference<br /><sup><sup>[<a href="qt3support.html">Qt3Support</a> module]</sup></sup></h1>
<p>The Q3TextBrowser class provides a rich text browser with hypertext navigation. <a href="#details">More...</a></p>
<pre> #include &lt;Q3TextBrowser&gt;</pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See <a href="porting4.html">Porting to Qt 4</a> for more information.</p>
<p>Inherits <a href="q3textedit.html">Q3TextEdit</a>.</p>
<ul>
<li><a href="q3textbrowser-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h3>Properties</h3>
<ul>
<li><div class="fn"/><b><a href="q3textbrowser.html#source-prop">source</a></b> : QString</li>
</ul>
<ul>
<li><div class="fn"/>19 properties inherited from <a href="q3textedit.html#properties">Q3TextEdit</a></li>
<li><div class="fn"/>10 properties inherited from <a href="q3scrollview.html#properties">Q3ScrollView</a></li>
<li><div class="fn"/>2 properties inherited from <a href="q3frame.html#properties">Q3Frame</a></li>
<li><div class="fn"/>6 properties inherited from <a href="qframe.html#properties">QFrame</a></li>
<li><div class="fn"/>56 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="q3textbrowser.html#Q3TextBrowser">Q3TextBrowser</a></b> ( QWidget * <i>parent</i> = 0, const char * <i>name</i> = 0 )</li>
<li><div class="fn"/>QString <b><a href="q3textbrowser.html#source-prop">source</a></b> () const</li>
</ul>
<ul>
<li><div class="fn"/>51 public functions inherited from <a href="q3textedit.html#public-functions">Q3TextEdit</a></li>
<li><div class="fn"/>46 public functions inherited from <a href="q3scrollview.html#public-functions">Q3ScrollView</a></li>
<li><div class="fn"/>4 public functions inherited from <a href="q3frame.html#public-functions">Q3Frame</a></li>
<li><div class="fn"/>13 public functions inherited from <a href="qframe.html#public-functions">QFrame</a></li>
<li><div class="fn"/>201 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
<li><div class="fn"/>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
<li><div class="fn"/>12 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
</ul>
<a name="public-slots"></a>
<h3>Public Slots</h3>
<ul>
<li><div class="fn"/>virtual void <b><a href="q3textbrowser.html#backward">backward</a></b> ()</li>
<li><div class="fn"/>virtual void <b><a href="q3textbrowser.html#forward">forward</a></b> ()</li>
<li><div class="fn"/>virtual void <b><a href="q3textbrowser.html#home">home</a></b> ()</li>
<li><div class="fn"/>virtual void <b><a href="q3textbrowser.html#reload">reload</a></b> ()</li>
<li><div class="fn"/>virtual void <b><a href="q3textbrowser.html#source-prop">setSource</a></b> ( const QString &amp; <i>name</i> )</li>
<li><div class="fn"/>void <b><a href="q3textbrowser.html#setText">setText</a></b> ( const QString &amp; <i>txt</i> )</li>
</ul>
<ul>
<li><div class="fn"/>60 public slots inherited from <a href="q3textedit.html#public-slots">Q3TextEdit</a></li>
<li><div class="fn"/>8 public slots inherited from <a href="q3scrollview.html#public-slots">Q3ScrollView</a></li>
<li><div class="fn"/>19 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h3>Signals</h3>
<ul>
<li><div class="fn"/>void <b><a href="q3textbrowser.html#anchorClicked">anchorClicked</a></b> ( const QString &amp; <i>name</i>, const QString &amp; <i>link</i> )</li>
<li><div class="fn"/>void <b><a href="q3textbrowser.html#backwardAvailable">backwardAvailable</a></b> ( bool <i>available</i> )</li>
<li><div class="fn"/>void <b><a href="q3textbrowser.html#forwardAvailable">forwardAvailable</a></b> ( bool <i>available</i> )</li>
<li><div class="fn"/>void <b><a href="q3textbrowser.html#highlighted">highlighted</a></b> ( const QString &amp; <i>link</i> )</li>
<li><div class="fn"/>void <b><a href="q3textbrowser.html#linkClicked">linkClicked</a></b> ( const QString &amp; <i>link</i> )</li>
<li><div class="fn"/>void <b><a href="q3textbrowser.html#sourceChanged">sourceChanged</a></b> ( const QString &amp; <i>src</i> )</li>
</ul>
<ul>
<li><div class="fn"/>14 signals inherited from <a href="q3textedit.html#signals">Q3TextEdit</a></li>
<li><div class="fn"/>5 signals inherited from <a href="q3scrollview.html#signals">Q3ScrollView</a></li>
<li><div class="fn"/>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<a name="protected-functions"></a>
<h3>Protected Functions</h3>
<ul>
<li><div class="fn"/>virtual void <b><a href="q3textbrowser.html#keyPressEvent">keyPressEvent</a></b> ( QKeyEvent * <i>e</i> )</li>
</ul>
<ul>
<li><div class="fn"/>6 protected functions inherited from <a href="q3textedit.html#protected-functions">Q3TextEdit</a></li>
<li><div class="fn"/>17 protected functions inherited from <a href="q3scrollview.html#protected-functions">Q3ScrollView</a></li>
<li><div class="fn"/>5 protected functions inherited from <a href="q3frame.html#protected-functions">Q3Frame</a></li>
<li><div class="fn"/>38 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
<li><div class="fn"/>1 protected function inherited from <a href="qpaintdevice.html#protected-functions">QPaintDevice</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"/>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
<li><div class="fn"/>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
<li><div class="fn"/>1 protected slot inherited from <a href="qwidget.html#protected-slots">QWidget</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The Q3TextBrowser class provides a rich text browser with hypertext navigation.</p>
<p>This class extends <a href="q3textedit.html">Q3TextEdit</a> (in read-only mode), adding some navigation functionality so that users can follow links in hypertext documents. The contents of <a href="q3textedit.html">Q3TextEdit</a> is set with <a href="q3textbrowser.html#setText">setText</a>(), but Q3TextBrowser has an additional function, <a href="q3textbrowser.html#source-prop">setSource</a>(), which makes it possible to set the text to a named document. The name is looked up in the text view's mime source factory. If a document name ends with an anchor (for example, &quot;<tt>#anchor&quot;</tt>), the text browser automatically scrolls to that position (using <a href="q3textedit.html#scrollToAnchor">scrollToAnchor</a>()). When the user clicks on a hyperlink, the browser will call <a href="q3textbrowser.html#source-prop">setSource</a>() itself, with the link's <tt>href</tt> value as argument. You can track the current source by connetion to the <a href="q3textbrowser.html#sourceChanged">sourceChanged</a>() signal.</p>
<p>Q3TextBrowser provides <a href="q3textbrowser.html#backward">backward</a>() and <a href="q3textbrowser.html#forward">forward</a>() slots which you can use to implement Back and Forward buttons. The <a href="q3textbrowser.html#home">home</a>() slot sets the text to the very first document displayed. The <a href="q3textbrowser.html#linkClicked">linkClicked</a>() signal is emitted when the user clicks a link.</p>
<p>By using <a href="q3textedit.html#setMimeSourceFactory">Q3TextEdit::setMimeSourceFactory</a>() you can provide your own subclass of <a href="q3mimesourcefactory.html">Q3MimeSourceFactory</a>. This makes it possible to access data from anywhere, for example from a network or from a database. See <a href="q3mimesourcefactory.html#data">Q3MimeSourceFactory::data</a>() for details.</p>
<p>If you intend using the mime factory to read the data directly from the file system, you may have to specify the encoding for the file extension you are using. For example:</p>
<pre> mimeSourceFactory()-&gt;setExtensionType(&quot;qml&quot;, &quot;text/utf8&quot;);</pre>
<p>This is to ensure that the factory is able to resolve the document names.</p>
<p>Q3TextBrowser interprets the tags it processes in accordance with the default style sheet. Change the style sheet with <a href="q3textedit.html#setStyleSheet">setStyleSheet</a>(); see <a href="porting4.html#qstylesheet">QStyleSheet</a> for details.</p>
<p>If you want to provide your users with editable rich text use <a href="q3textedit.html">Q3TextEdit</a>. If you want a text browser without hypertext navigation use <a href="q3textedit.html">Q3TextEdit</a>, and use <a href="q3textedit.html#readOnly-prop">Q3TextEdit::setReadOnly</a>() to disable editing. If you just need to display a small piece of rich text use <a href="porting4.html#qsimplerichtext">QSimpleRichText</a> or <a href="qlabel.html">QLabel</a>.</p>
<hr />
<h2>Property Documentation</h2>
<h3 class="fn"><a name="source-prop"></a>source : <a href="qstring.html">QString</a></h3>
<p>This property holds the name of the displayed document.</p>
<p>This is a an empty string if no document is displayed or if the source is unknown.</p>
<p>Setting this property uses the <a href="q3textedit.html#mimeSourceFactory">mimeSourceFactory</a>() to lookup the named document. It also checks for optional anchors and scrolls the document accordingly.</p>
<p>If the first tag in the document is <tt>&lt;qt type=detail&gt;</tt>, the document is displayed as a popup rather than as new document in the browser window itself. Otherwise, the document is displayed normally in the text browser with the text set to the contents of the named document with <a href="q3textbrowser.html#setText">setText</a>().</p>
<p>If you are using the filesystem access capabilities of the mime source factory, you must ensure that the factory knows about the encoding of specified files; otherwise no data will be available. The default factory handles a couple of common file extensions such as <tt>*.html</tt> and <tt>*.txt</tt> with reasonable defaults. See <a href="q3mimesourcefactory.html#data">Q3MimeSourceFactory::data</a>() for details.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>QString source () const</b></li>
<li><div class="fn"/><b>virtual void setSource ( const QString &amp; <i>name</i> )</b></li>
</ul>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="Q3TextBrowser"></a>Q3TextBrowser::Q3TextBrowser ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0, const char * <i>name</i> = 0 )</h3>
<p>Constructs an empty <a href="q3textbrowser.html">Q3TextBrowser</a> called <i>name</i>, with parent <i>parent</i>.</p>
<h3 class="fn"><a name="anchorClicked"></a>void Q3TextBrowser::anchorClicked ( const <a href="qstring.html">QString</a> &amp; <i>name</i>, const <a href="qstring.html">QString</a> &amp; <i>link</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted when the user clicks an anchor. The <i>link</i> is the value of the <tt>href</tt> i.e&#x2e; the name of the target document. The <i>name</i> is the name of the anchor.</p>
<p>See also <a href="q3textbrowser.html#linkClicked">linkClicked</a>().</p>
<h3 class="fn"><a name="backward"></a>void Q3TextBrowser::backward ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
<p>Changes the document displayed to the previous document in the list of documents built by navigating links. Does nothing if there is no previous document.</p>
<p>See also <a href="q3textbrowser.html#forward">forward</a>() and <a href="q3textbrowser.html#backwardAvailable">backwardAvailable</a>().</p>
<h3 class="fn"><a name="backwardAvailable"></a>void Q3TextBrowser::backwardAvailable ( bool <i>available</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted when the availability of <a href="q3textbrowser.html#backward">backward</a>() changes. <i>available</i> is false when the user is at <a href="q3textbrowser.html#home">home</a>(); otherwise it is true.</p>
<h3 class="fn"><a name="forward"></a>void Q3TextBrowser::forward ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
<p>Changes the document displayed to the next document in the list of documents built by navigating links. Does nothing if there is no next document.</p>
<p>See also <a href="q3textbrowser.html#backward">backward</a>() and <a href="q3textbrowser.html#forwardAvailable">forwardAvailable</a>().</p>
<h3 class="fn"><a name="forwardAvailable"></a>void Q3TextBrowser::forwardAvailable ( bool <i>available</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted when the availability of <a href="q3textbrowser.html#forward">forward</a>() changes. <i>available</i> is true after the user navigates <a href="q3textbrowser.html#backward">backward</a>() and false when the user navigates or goes <a href="q3textbrowser.html#forward">forward</a>().</p>
<h3 class="fn"><a name="highlighted"></a>void Q3TextBrowser::highlighted ( const <a href="qstring.html">QString</a> &amp; <i>link</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted when the user has selected but not activated a link in the document. <i>link</i> is the value of the <tt>href</tt> i.e&#x2e; the name of the target document.</p>
<h3 class="fn"><a name="home"></a>void Q3TextBrowser::home ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
<p>Changes the document displayed to be the first document the browser displayed.</p>
<h3 class="fn"><a name="keyPressEvent"></a>void Q3TextBrowser::keyPressEvent ( <a href="qkeyevent.html">QKeyEvent</a> * <i>e</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>The event <i>e</i> is used to provide the following keyboard shortcuts:</p>
<p><table align="center" cellpadding="2" cellspacing="1" border="0">
<thead><tr valign="top" class="qt-style"><th>Keypress</th><th>Action</th></tr></thead>
<tr valign="top" class="odd"><td>Alt+Left Arrow</td><td><a href="q3textbrowser.html#backward">backward</a>()</td></tr>
<tr valign="top" class="even"><td>Alt+Right Arrow</td><td><a href="q3textbrowser.html#forward">forward</a>()</td></tr>
<tr valign="top" class="odd"><td>Alt+Up Arrow</td><td><a href="q3textbrowser.html#home">home</a>()</td></tr>
</table></p>
<p>Reimplemented from <a href="qwidget.html#keyPressEvent">QWidget</a>.</p>
<h3 class="fn"><a name="linkClicked"></a>void Q3TextBrowser::linkClicked ( const <a href="qstring.html">QString</a> &amp; <i>link</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted when the user clicks a link. The <i>link</i> is the value of the <tt>href</tt> i.e&#x2e; the name of the target document.</p>
<p>The <i>link</i> will be the absolute location of the document, based on the value of the anchor's href tag and the current context of the document.</p>
<p>See also <a href="q3textbrowser.html#anchorClicked">anchorClicked</a>().</p>
<h3 class="fn"><a name="reload"></a>void Q3TextBrowser::reload ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
<p>Reloads the current set source.</p>
<h3 class="fn"><a name="setText"></a>void Q3TextBrowser::setText ( const <a href="qstring.html">QString</a> &amp; <i>txt</i> )&nbsp;&nbsp;<tt> [slot]</tt></h3>
<p>Sets the text to <i>txt</i>.</p>
<h3 class="fn"><a name="sourceChanged"></a>void Q3TextBrowser::sourceChanged ( const <a href="qstring.html">QString</a> &amp; <i>src</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted when the mime source has changed, <i>src</i> being the new source.</p>
<p>Source changes happen both programmatically when calling <a href="q3textbrowser.html#source-prop">setSource</a>(), <a href="q3textbrowser.html#forward">forward</a>(), backword() or <a href="q3textbrowser.html#home">home</a>() or when the user clicks on links or presses the equivalent key sequences.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2008 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.3.5</div></td>
</tr></table></div></address></body>
</html>
